package com.hong.taotaomall.utils;

import java.io.UnsupportedEncodingException;
import java.util.Random;

public class RandomUserInfoUtlis {
    public static void main(String[] args) {
        System.out.println(getRandomIdNumber());
    }
    public static String getRandomUserName(int len) {
        String ret = "";
        for (int i = 0; i < len; i++) {
            String str = null;
            int hightPos, lowPos; // 定义高低位
            Random random = new Random();
            hightPos = (176 + Math.abs(random.nextInt(39))); // 获取高位值
            lowPos = (161 + Math.abs(random.nextInt(93))); // 获取低位值
            byte[] b = new byte[2];
            b[0] = (new Integer(hightPos).byteValue());
            b[1] = (new Integer(lowPos).byteValue());
            try {
                str = new String(b, "GBK"); // 转成中文
            } catch (UnsupportedEncodingException ex) {
                ex.printStackTrace();
            }
            ret += str;
        }
        return ret;
    }


    public static String getRandomIdNumber(){
        Integer code =null;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 3; i++) {
            code = new Random().nextInt(999999);//生成随机数，最大为999999
            if(code < 100000){
                code = code + 100000;//保证随机数为6位数字
            }
            sb.append(code);
        }
        return sb.toString();
    }
}
